package day1.Exer527;
/**
 * 统计各种性别的人数，并输出
 */

import day1.Exer.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Exer1 {
    public static void main(String[] args) {
        String sql="select sex, count(stuno) from s_student   GROUP BY sex";
        try {
            Connection con= DBUtil.getConnection();
            PreparedStatement pst=con.prepareStatement(sql);
            ResultSet rs=pst.executeQuery();
            while(rs.next()){
                System.out.println(rs.getString("sex")+rs.getInt("count(stuno)"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
